<?php
	function displayPage()
	{
		$output = '
		<div class="container_12">
			<div class="grid_12 mailListIntro">
				<img src="./img/mailingList.png" />
			</div>
		</div>
		';
		if(post('6752491208567') == '921084670968345' || get('09123682346') != 'null')
		{
			$emailS = (post('subscribe') == 'null' ? get('09123682346') : post('subscribe'));
		
			$tables = array();
			$tables[0] = 'ex_mailingList';
			
			$fields = array();
			$fields[0] = 'listID';
			
			$whereClause = 'address="'.$emailS.'"';
			
			
			$output .= '
			<div class="container_12">
				<div class="grid_12">
					<p>';
			if(verifyEmail($emailS))
			{
				$data = SQLRecover($tables, $fields, $whereClause);
				
				echo sendThisEmail('<html><head></head><body><div style="padding-top: 40px; border-bottom: 5px solid #d3d3d3; margin-bottom: 10px;"><img src="http://soleservice.com.ph/img/mailingList.png" /></div>You have successfully subscribed to our mailing list. To unsubscribe, enter this address into your browser:<br /><br />'.INDEX.'0269458670'.EXT.'921084670968345='.$emailS.'</body></html>', 'Mailing List Update', '', '', $emailS, 'Mailing List <announcement@soleservice.com.ph>', true);
				
				if($data['queryStatus'] != 'DB Query success!')
				{
					$tableName = 'ex_mailingList';
					
					$fields = array();
					$fields[0] = 'address';
					
					$values = array();
					$values[0] = $emailS;
					
					$data = SQLInsert($tableName, $fields, $values);
				}
				
				$output .= 'You have successfully subscribed to our mailing list. You will receive emails regarding our future announcements from our site. Thank you for subscribing!
					</p>
				</div>
			</div>
				';
			}
			else
			{
				$output .= 'You have entered an invalid email address. Click <a href="'.INDEX.'home"><b>here</b></a> to go back.
					</p>
				</div>
			</div>
			';
			}
			
			
		}
		else if(get('921084670968345') != 'null')
		{
			$tables = array();
			$tables[0] = 'ex_mailingList';
			
			$fields = array();
			$fields[0] = 'address';
			
			$whereClause = 'address="'.get('921084670968345').'"';
			
			$data = SQLRecover($tables, $fields, $whereClause);
			
			if(isset($data['address'][0]))
			{
				$output .= '
				<div class="container_12">
					<div class="grid_12">
						<p>
							 Your email is '.get('921084670968345').' and is currently subscribed to our mailing list. Do you wish to unsubscribe? If you unsubscribe from our mailing list, you will not receive updates and announcements from Sole Service Manila. Are you sure you want to continue?
						</p>
						<p class="centerAlign">
							<input type="button" class="mailingList" value="Yes, I would like to delete my subscription." id="unsub" rel="'.INDEX.'0269458670'.EXT.'81389056238='.get('921084670968345').'"/>
						</p>
					</div>
				</div>
				';
			}
			else
			{
				$output = 'Error 404: File Not Found.';
			}
		}
		else if(get('81389056238') != 'null')
		{
			$data = SQLDelete ('ex_mailingList', 'address="'.get('81389056238').'"');
			$output .= '
				<div class="container_12">
					<div class="grid_12">
						<p>
							 You have successfully unsubscribed to our mailing list. We hope to hear from you in the future!
						</p>
					</div>
				</div>
				';
		}
		else
		{
			$output = 'Error 404: File Not Found.';
		}
		return $output;
	}
?>